<?php

session_start();

$customer_id = $_SESSION['userid'];

include "connect.php";

$product_id = $_POST['product_row_id'];
$customer_name = $_POST['customer_name'];
$customer_feedback = $_POST['customer_feedback'];
$today = date("Y,m,d");


	mysql_query("INSERT INTO customer_feedback

	(
	
	feedback_date,
	customer_name,
	feedback,
	feedback_status,
	product_id
		
	) 
	
	VALUES
	
	(
	'$today',
	'$customer_name',
	'$customer_feedback',
	'New',
	'$product_id')
	
	 "); 

		/////////////////////////
		//Send message as email
		/////////////////////////


if($_POST['send_customer_email'] == "Yes")

{
	
	$query = "SELECT * FROM saddles WHERE product_id = '$product_id'";
	$result = mysql_query($query);
	
	while($row = mysql_fetch_array($result))
	 
	 {
		 
	$product_cost = $row['product_cost'];
	$product_name = $row['product_name']; 
	$product_row_id = $row['id'];
	
	 }
	
		$to      = "sean.richardson@hotmail.co.uk";
		$subject = 'Product message';
			
		$message = file_get_contents('admin_files/emails/product_message_email.html');
		
		$message = str_replace("{SADDLE_NAME}",$product_name,$message);
		$message = str_replace("{SADDLE_COST}",$product_cost,$message);
		$message = str_replace("{SADDLE_PRODUCT_ID}",$product_id,$message);
		$message = str_replace("{SADDLE_ROW_ID}",$product_row_id,$message);
		$message = str_replace("{SADDLE_MESSAGE}",$contact_message,$message);		
				
		$headers = "From: 24-7Saddles.com <Sales@24-7saddles.com>\r\n";
		$headers .= "MIME-Version: 1.0\r\n";
		$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";

		mail($to, $subject, $message, $headers);

}
		
		/////
		//End
		/////


//echo $product_id;

header('Location: contact_us_landing_page.php?');


?>